
package com.sfdlJPush.utils;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;

import com.sfdlJPush.R;
import com.sfdlJPush.controller.MainApplication;

public class NotificationManagerUtil
{
    static NotificationManager mNotificationManager = (NotificationManager) MainApplication.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);

    public static void showDefaultResourceMessage(String message , Context context , int requestCode , Intent intent)
    {
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_launcher).setContentTitle("sfdlJPush").setContentText(message);
        mBuilder.setAutoCancel(true);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addNextIntent(intent);
        PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
        mBuilder.setContentIntent(resultPendingIntent);
        mNotificationManager.notify(requestCode, mBuilder.build());
    }

    public static void cancelNotification(int requestCode)
    {
        mNotificationManager.cancel(requestCode);
    }
}
